package cliente;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import javax.swing.border.Border;




public class VentanaIP extends JFrame{
	
	/**
	 * Muestra el progreso de carga.
	 */
	public JProgressBar progressBar;
	
	public static void main(String[] args) {
		VentanaIP vIP = new VentanaIP();

		
		vIP.setVisible(true);

		try {

			//Entre cada progreso de carga avanza el progresbar.
			int t = 0;
			int total = 7;

			//Tiempo que espera entre cada progreso
			long sleept = 500L;

			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);

			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);
			
			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);

			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);
			
			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);

			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);
			
			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);

			t++;
			vIP.progressBar.setValue(t * 100 / total);
			Thread.sleep(sleept);			

			

		} catch (Exception e) {

			e.printStackTrace();

		}
		
		//Se cierra la ventana de carga y se inicia el programa
		vIP.dispose();
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
//					VentanaSplash frame = new VentanaSplash();
//					frame.setVisible(true);
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
	}
	
	/**
	 * Creacion de la ventana con toda su configuraci�n.
	 */
	public VentanaIP() {
		//Configuraci�n de la ventana
		getContentPane().setBackground(SystemColor.inactiveCaption);
		setResizable(false);
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 447, 253);
		this.setUndecorated(true);
		getContentPane().setLayout(null);

		//Coloca la ventana en el centro de la pantalla.
		Toolkit toolkit = getToolkit();
		Dimension size = toolkit.getScreenSize();
		setLocation(size.width/2-getWidth()/2, size.height/2-getHeight()/2);

		//Creaccion e inserccion de los componenetes de la ventana
		JLabel lblCargando = new JLabel("Estableciendo conexi\u00F3n IP...");
		lblCargando.setHorizontalAlignment(SwingConstants.CENTER);
		lblCargando.setBounds(51, 134, 331, 30);
		lblCargando.setForeground(SystemColor.inactiveCaptionBorder);
		lblCargando.setFont(new Font("Trebuchet MS", Font.PLAIN, 18));
		getContentPane().add(lblCargando);

		progressBar = new JProgressBar();
		progressBar.setBounds(0, 196, 440, 21);
		progressBar.setStringPainted(true);
		progressBar.setBackground(Color.YELLOW);
			
		getContentPane().add(progressBar);

//		JLabel label = new JLabel("");
//		label.setBounds(0, 0, 440, 286);
//		label.setIcon(new ImageIcon("imagenesBasicas/splash.jpg"));
//		getContentPane().add(label);
		
		

	}


}
